//
//  LawProblemViewTableViewCell.m
//  yonghu
//
//  Created by 浪尖渝力 on 2018/1/19.
//  Copyright © 2018年 com.DJS. All rights reserved.
//

#import "LawProblemViewTableViewCell.h"

@implementation LawProblemViewTableViewCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}
-(void)creatView{
    
    self.backgroundColor=_LightGrey;
    UIView *beiJinView=[UIView new];
    [self addSubview:beiJinView];
    [beiJinView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(5);
        make.right.mas_equalTo(-5);
        make.top.mas_equalTo(7);
        make.bottom.mas_equalTo(0);
    }];
    beiJinView.backgroundColor=[UIColor whiteColor];
    beiJinView.layer.cornerRadius=3;
    
    UIImageView *imageView=[UIImageView new];
    [beiJinView addSubview:imageView];
    [imageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(15);
        make.top.mas_equalTo(10);
        make.height.mas_equalTo(50);
        make.width.mas_equalTo(50);
    }];
    imageView.layer.cornerRadius=25;
    imageView.layer.masksToBounds=YES;
    NSString *news_cover=[_dic objectForKey:@"law_qa_image"];
    news_cover=[NSString stringWithFormat:@"%@%@",_addressUrl,news_cover];
    [imageView sd_setImageWithURL:[NSURL URLWithString:news_cover]];
    
    UILabel *tilteLabel2=[UILabel new];
    [beiJinView addSubview:tilteLabel2];
    [tilteLabel2 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(imageView.mas_right).mas_equalTo(15);
        make.right.mas_equalTo(-15);
        make.centerY.mas_equalTo(imageView);
    }];
    tilteLabel2.text=[_dic objectForKey:@"law_qa_question"];
    tilteLabel2.font=[UIFont systemFontOfSize:18];
    tilteLabel2.textColor=ColorWithRGB(49, 49, 49);
    
    NSString *nt_name=[_dic objectForKey:@"law_qa_answer"];
    
    UILabel *nameLabel=[UILabel new];
    [beiJinView addSubview:nameLabel];
    [nameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(10);
        make.right.mas_equalTo(-10);
        make.top.mas_equalTo(imageView.mas_bottom).mas_equalTo(15);
    }];
    
    NSAttributedString * attrStr = [[NSAttributedString alloc] initWithData:[nt_name  dataUsingEncoding:NSUnicodeStringEncoding] options:@{NSDocumentTypeDocumentAttribute: NSHTMLTextDocumentType,NSFontAttributeName:[UIFont systemFontOfSize:25.0f] } documentAttributes:nil error:nil];
    nameLabel.attributedText = attrStr;
    nameLabel.numberOfLines=2;
    nameLabel.font=[UIFont systemFontOfSize:16];
    nameLabel.textColor=ColorWithRGB(149, 149, 149);
    
    
    NSString *consult_ct_name=[_dic objectForKey:@"law_ct_name"];
    CGSize size=[ZQTools getNSStringWeight:consult_ct_name andViewWight:20 andFont:18];
    UILabel *ct_nameLabel=[UILabel new];
    [beiJinView addSubview:ct_nameLabel];
    [ct_nameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(10);
        make.height.mas_equalTo(30);
        make.bottom.mas_equalTo(-7);
        make.width.mas_equalTo(size.width+14);
    }];
    ct_nameLabel.text=consult_ct_name;
    ct_nameLabel.font=[UIFont systemFontOfSize:16];
    ct_nameLabel.layer.borderWidth=1;
    ct_nameLabel.layer.borderColor=ColorWithRGB(132, 189,226).CGColor;
    ct_nameLabel.textColor=ColorWithRGB(132, 189,226);
    [ct_nameLabel layoutIfNeeded];
    ct_nameLabel.textAlignment=NSTextAlignmentCenter;
    ct_nameLabel.layer.cornerRadius=4;
    
    
    NSNumber *time=[_dic objectForKey:@"law_qa_time"];
    
    UILabel *timeLabel=[UILabel new];
    [beiJinView addSubview:timeLabel];
    [timeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.mas_equalTo(-15);
        make.centerY.mas_equalTo(ct_nameLabel);
    }];
    timeLabel.text=[ZQTools changeTimeCuo:@"HH:mm yyyy-MM-dd":[NSString stringWithFormat:@"%@",time] ];
    timeLabel.font=[UIFont systemFontOfSize:14];
    timeLabel.textColor=ColorWithRGB(149, 149, 149);
    
    
}

@end
